<template>
  <div class="wrapper">
    <div class="header">
      <el-row v-if="this.$route.params.class === 14">
        <h3 style="font-family: '微软雅黑'">
          {{ nowYear }}湖北省高校实践育人特色项目结项审批表
        </h3>
      </el-row>
      <h3 v-if="this.class === 15" style="font-family: '微软雅黑'">
        {{ nowYear }}湖北省高校学生工作精品项目结项审批表
      </h3>
    </div>
    <div class="formall">
      <el-row><h4 class="intro-center">声明相关信息填写</h4></el-row>
      <el-row>
        <el-form
          :model="form"
          label-width="100px"
          :rules="rules"
          ref="form"
          class="demo-ruleForm"
          :loading="loading"
        >
          <el-row>
          <el-col :span="6">
            <el-form-item label="实际完成时间" prop="real_date">
              <el-date-picker
                class="cell-width"
                v-model="form.real_date"
                type="date"
                placeholder="请选择日期"
              >
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="申请鉴定时间" prop="identify_date">
              <el-date-picker
                class="cell-width"
                v-model="form.identify_date"
                type="date"
                placeholder="请选择日期"
              >
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-tooltip
              class="item"
              effect="dark"
              content="至少勾选一项至多两项"
              placement="top-start"
            >
              <el-form-item label="最终成果形式">
                <el-checkbox-group
                  style="width:100%"
                  v-model="final_result"
                  :min="1"
                  :max="2"
                  @change="mulCheckOne"
                >
                  <el-checkbox
                    v-for="item in achievements"
                    :key="item.value"
                    :label="item.title"
                    :value="item.id"
                  ></el-checkbox>
                </el-checkbox-group>
              </el-form-item>
            </el-tooltip>
          </el-col>
          </el-row>
          <el-col :span="24">
            <h4 class="intro-center">经费决算相关填写</h4>
          </el-col>
          <el-row>
          <el-col :span="8">
            <el-form-item label="书本费" prop="book_fee">
              <el-tooltip
                class="item"
                effect="dark"
                content="以“万元”为单位填写数字"
                placement="top-start"
              >
                <el-input
                  class="expense-width"
                  oninput="value=value.replace(/[^\d.]/g, '')"
                  v-model="form.book_fee"
                  placeholder="若无请填0"
                ></el-input>
              </el-tooltip>
              <span>
                <strong>(万元)</strong>
              </span>
            </el-form-item>
          </el-col>
          <el-col :span="16">
            <el-form-item label="依据及用途" prop="book_fee_basis">
              <el-input
                class="cell-width"
                v-model="form.book_fee_basis"
                placeholder="请输入书本费预算的依据及用途（非必填，可填写“无”，下同）"
                type="textarea"
                maxlength="200"
                show-word-limit
                autosize
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="数据采集费" prop="data_fee">
              <el-tooltip
                class="item"
                effect="dark"
                content="以“万元”为单位填写数字"
                placement="top-start"
              >
                <el-input
                  class="expense-width"
                  oninput="value=value.replace(/[^\d.]/g, '')"
                  v-model="form.data_fee"
                  placeholder="若无请填0"
                ></el-input>
              </el-tooltip>
              <span>
                <strong>(万元)</strong>
              </span>
            </el-form-item>
          </el-col>
          <el-col :span="16">
            <el-form-item label="依据及用途" prop="book_fee_basis">
              <el-input
                class="cell-width"
                type="textarea"
                autosize
                v-model="form.data_fee_basis"
                placeholder="若无请填0"
                maxlength="200"
                show-word-limit
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="差旅费" prop="travel_fee">
              <el-tooltip
                class="item"
                effect="dark"
                content="以“万元”为单位填写数字"
                placement="top-start"
              >
                <el-input
                  class="expense-width"
                  oninput="value=value.replace(/[^\d.]/g, '')"
                  v-model="form.travel_fee"
                  placeholder="若无请填0"
                ></el-input>
              </el-tooltip>
              <span>
                <strong>(万元)</strong>
              </span>
            </el-form-item>
          </el-col>
          <el-col :span="16">
            <el-form-item label="依据及用途" prop="travel_fee_basis">
              <el-input
                class="cell-width"
                type="textarea"
                autosize
                v-model="form.travel_fee_basis"
                placeholder="请输入差旅费预算的依据及用途（非必填）"
                maxlength="200"
                show-word-limit
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="会议费" prop="meeting_fee">
              <el-tooltip
                class="item"
                effect="dark"
                content="以“万元”为单位填写数字"
                placement="top-start"
              >
                <el-input
                  class="expense-width"
                  oninput="value=value.replace(/[^\d.]/g, '')"
                  v-model="form.meeting_fee"
                  placeholder="若无请填0"
                ></el-input>
              </el-tooltip>
              <span>
                <strong>(万元)</strong>
              </span>
            </el-form-item>
          </el-col>
          <el-col :span="16">
            <el-form-item label="依据及用途" prop="meeting_fee_basis">
              <el-input
                class="cell-width"
                type="textarea"
                autosize
                v-model="form.meeting_fee_basis"
                placeholder="请输入会议费预算的依据及用途（非必填）"
                maxlength="200"
                show-word-limit
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="国际合作费" prop="international_fee">
              <el-tooltip
                class="item"
                effect="dark"
                content="以“万元”为单位填写数字"
                placement="top-start"
              >
                <el-input
                  class="expense-width"
                  oninput="value=value.replace(/[^\d.]/g, '')"
                  v-model="form.international_fee"
                  placeholder="若无请填0"
                ></el-input>
              </el-tooltip>
              <span>
                <strong>(万元)</strong>
              </span>
            </el-form-item>
          </el-col>
          <el-col :span="16">
            <el-form-item label="依据及用途" prop="international_fee_basis">
              <el-input
                class="cell-width"
                type="textarea"
                autosize
                v-model="form.international_fee_basis"
                placeholder="请输入国际交流合作费预算的依据及用途（非必填）"
                maxlength="200"
                show-word-limit
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="设备费" prop="equipment_fee">
              <el-tooltip
                class="item"
                effect="dark"
                content="以“万元”为单位填写数字"
                placement="top-start"
              >
                <el-input
                  class="expense-width"
                  oninput="value=value.replace(/[^\d.]/g, '')"
                  v-model="form.equipment_fee"
                  placeholder="若无请填0"
                ></el-input>
              </el-tooltip>
              <span>
                <strong>(万元)</strong>
              </span>
            </el-form-item>
          </el-col>
          <el-col :span="16">
            <el-form-item label="依据及用途" prop="equipment_fee_basis">
              <el-input
                class="cell-width"
                type="textarea"
                autosize
                v-model="form.equipment_fee_basis"
                placeholder="请输入设备费预算的依据及用途（非必填）"
                maxlength="200"
                show-word-limit
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="专家咨询费" prop="consulting_fee">
              <el-tooltip
                class="item"
                effect="dark"
                content="以“万元”为单位填写数字"
                placement="top-start"
              >
                <el-input
                  class="expense-width"
                  oninput="value=value.replace(/[^\d.]/g, '')"
                  v-model="form.consulting_fee"
                  placeholder="若无请填0"
                ></el-input>
              </el-tooltip>
              <span>
                <strong>(万元)</strong>
              </span>
            </el-form-item>
          </el-col>
          <el-col :span="16">
            <el-form-item label="依据及用途" prop="consulting_fee_basis">
              <el-input
                class="cell-width"
                type="textarea"
                autosize
                v-model="form.consulting_fee_basis"
                placeholder="请输入专家咨询费预算的依据及用途（非必填）"
                maxlength="200"
                show-word-limit
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="劳务费" prop="labour_fee">
              <el-tooltip
                class="item"
                effect="dark"
                content="以“万元”为单位填写数字"
                placement="top-start"
              >
                <el-input
                  class="expense-width"
                  oninput="value=value.replace(/[^\d.]/g, '')"
                  v-model="form.labour_fee"
                  placeholder="若无请填0"
                ></el-input>
              </el-tooltip>
              <span>
                <strong>(万元)</strong>
              </span>
            </el-form-item>
          </el-col>
          <el-col :span="16">
            <el-form-item label="依据及用途" prop="labour_fee_basis">
              <el-input
                class="cell-width"
                type="textarea"
                autosize
                v-model="form.labour_fee_basis"
                placeholder="请输入劳务费预算的依据及用途（非必填）"
                maxlength="200"
                show-word-limit
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="印刷费" prop="print_fee">
              <el-tooltip
                class="item"
                effect="dark"
                content="以“万元”为单位填写数字"
                placement="top-start"
              >
                <el-input
                  class="expense-width"
                  oninput="value=value.replace(/[^\d.]/g, '')"
                  v-model="form.print_fee"
                  placeholder="若无请填0"
                ></el-input>
              </el-tooltip>
              <span>
                <strong>(万元)</strong>
              </span>
            </el-form-item>
          </el-col>
          <el-col :span="16">
            <el-form-item label="依据及用途" prop="book_fee_basis">
              <el-input
                class="cell-width"
                type="textarea"
                autosize
                v-model="form.print_fee_basis"
                placeholder="请输入印刷费预算的依据及用途（非必填）"
                maxlength="200"
                show-word-limit
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="管理费" prop="administration_fee">
              <el-tooltip
                class="item"
                effect="dark"
                content="以“万元”为单位填写数字"
                placement="top-start"
              >
                <el-input
                  class="expense-width"
                  oninput="value=value.replace(/[^\d.]/g, '')"
                  v-model="form.administration_fee"
                  placeholder="若无请填0"
                ></el-input>
              </el-tooltip>
              <span>
                <strong>(万元)</strong>
              </span>
            </el-form-item>
          </el-col>
          <el-col :span="16">
            <el-form-item label="依据及用途" prop="administration_fee_basis">
              <el-input
                class="cell-width"
                type="textarea"
                autosize
                v-model="form.administration_fee_basis"
                placeholder="请输入管理费预算的依据及用途（非必填）"
                maxlength="200"
                show-word-limit
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="其他支出" prop="other_fee">
              <el-tooltip
                class="item"
                effect="dark"
                content="以“万元”为单位填写数字"
                placement="top-start"
              >
                <el-input
                  class="expense-width"
                  oninput="value=value.replace(/[^\d.]/g, '')"
                  v-model="form.other_fee"
                  placeholder="若无请填0"
                ></el-input>
              </el-tooltip>
              <span>
                <strong>(万元)</strong>
              </span>
            </el-form-item>
          </el-col>
          <el-col :span="16">
            <el-form-item label="依据及用途" prop="other_fee_basis">
              <el-input
                class="cell-width"
                type="textarea"
                autosize
                v-model="form.other_fee_basis"
                placeholder="请输入其他支出预算的依据及用途（非必填）"
                maxlength="200"
                show-word-limit
              ></el-input>
            </el-form-item>
          </el-col>
          </el-row>
          <el-form-item label="合计" prop="all_fee">
              {{all_fee}} <strong>(万元)</strong>
            </el-form-item>
            <el-col :span="24">
              <h4 class="intro-center">资助经费统计</h4>
            </el-col>
          <el-row>
          <el-col :span="6" v-if="this.$route.params.class == 14">
            <el-form-item label="批准经费" prop="agr_expense">
              <el-tooltip
                class="item"
                effect="dark"
                content="以“万元”为单位填写数字"
                placement="top-start"
              >
                <el-input
                  style="width:70%"
                  oninput="value=value.replace(/[^\d.]/g, '')"
                  v-model="form.agr_expense"
                  placeholder="请输入金额"
                ></el-input>
              </el-tooltip>
              <span>
                <strong>(万元)</strong>
              </span>
            </el-form-item>
          </el-col>
          <el-col :span="6" v-if="this.$route.params.class == 14">
            <el-form-item label="实拨经费" prop="real_expense">
              <el-tooltip
                class="item"
                effect="dark"
                content="以“万元”为单位填写数字"
                placement="top-start"
              >
                <el-input
                  style="width:70%"
                  oninput="value=value.replace(/[^\d.]/g, '')"
                  v-model="form.real_expense"
                  placeholder="输入批准经费对应的实拨经费"
                ></el-input>
              </el-tooltip>
              <span>
                <strong>(万元)</strong>
              </span>
            </el-form-item>
          </el-col>
          <el-col :span="6" v-if="this.$route.params.class == 14">
            <el-form-item label="配套经费" prop="mating_expense ">
              <el-tooltip
                class="item"
                effect="dark"
                content="以“万元”为单位填写数字"
                placement="top-start"
              >
                <el-input
                  style="width:70%"
                  oninput="value=value.replace(/[^\d.]/g, '')"
                  v-model="form.mating_expense"
                  placeholder="请输入金额"
                ></el-input>
              </el-tooltip>
              <span>
                <strong>(万元)</strong>
              </span>
            </el-form-item>
          </el-col>
          <el-col :span="6" v-if="this.$route.params.class == 14">
            <el-form-item label="实拨经费" prop="matreal_expense ">
              <el-tooltip
                class="item"
                effect="dark"
                content="以“万元”为单位填写数字"
                placement="top-start"
              >
                <el-input
                  style="width:70%"
                  oninput="value=value.replace(/[^\d.]/g, '')"
                  v-model="form.matreal_expense"
                  placeholder="输入配套经费对应的实拨经费"
                ></el-input>
              </el-tooltip>
              <span>
                <strong>(万元)</strong>
              </span>
            </el-form-item>
          </el-col>
          <el-col :span="6" v-if="this.$route.params.class == 14">
            <el-form-item label="项目实际总经费" prop="realtotal_expense">
              {{realtotal_expense}}
             <!--  <el-tooltip
                class="item"
                effect="dark"
                content="以“万元”为单位填写数字"
                placement="top-start"
              >
                <el-input
                  style="width:70%"
                  oninput="value=value.replace(/[^\d.]/g, '')"
                  v-model="form.realtotal_expense"
                  placeholder="请输入项目实际总经费"
                ></el-input> -->
              </el-tooltip>
              <span>
                <strong>(万元)</strong>
              </span>
            </el-form-item>
          </el-col>
          <el-col :span="6" v-show="this.$route.params.class == 15">
            <el-form-item label="省级资助" prop="agr_expense">
              <el-tooltip
                class="item"
                effect="dark"
                content="以“万元”为单位填写数字"
                placement="top-start"
              >
                <el-input
                  style="width:70%"
                  oninput="value=value.replace(/[^\d.]/g, '')"
                  v-model="form.provincial_fund"
                  placeholder="请输入金额"
                ></el-input>
              </el-tooltip>
              <span>
                <strong>(万元)</strong>
              </span>
            </el-form-item>
          </el-col>
          <el-col :span="6" v-if="this.$route.params.class == 15">
            <el-form-item label="学校配套资助" prop="real_expense">
              <el-tooltip
                class="item"
                effect="dark"
                content="以“万元”为单位填写数字"
                placement="top-start"
              >
                <el-input
                  style="width:70%"
                  oninput="value=value.replace(/[^\d.]/g, '')"
                  v-model="form.sch_fund"
                  placeholder="输入批准经费对应的实拨经费"
                ></el-input>
              </el-tooltip>
              <span>
                <strong>(万元)</strong>
              </span>
            </el-form-item>
          </el-col>
          <el-col :span="6" v-if="this.$route.params.class == 15">
            <el-form-item label="个人自筹" prop="mating_expense ">
              <el-tooltip
                class="item"
                effect="dark"
                content="以“万元”为单位填写数字"
                placement="top-start"
              >
                <el-input
                  style="width:70%"
                  oninput="value=value.replace(/[^\d.]/g, '')"
                  v-model="form.personal_fund"
                  placeholder="请输入金额"
                ></el-input>
              </el-tooltip>
              <span>
                <strong>(万元)</strong>
              </span>
            </el-form-item>
          </el-col>
          <el-col :span="6" v-if="this.$route.params.class == 15">
            <el-form-item label="总经费" prop="funds ">
              {{funds}}
            <!--   <el-tooltip
                class="item"
                effect="dark"
                content="以“万元”为单位填写数字"
                placement="top-start"
              >
                <el-input
                  style="width:70%"
                  oninput="value=value.replace(/[^\d.]/g, '')"
                  v-model="form.funds"
                  placeholder="输入配套经费对应的实拨经费"
                ></el-input>
              </el-tooltip> -->
              <span>
                <strong>(万元)</strong>
              </span>
            </el-form-item>
          </el-col>
          </el-row>
        </el-form>
      </el-row>

      <el-row>
        <el-col :span="24">
          <div style="text-align:center">
            <h4 style="display: inline-block">主要成果</h4>
            <el-tooltip
              class="item"
              effect="dark"
              content="点击添加主要成果"
              placement="top-start"
            >
              <el-button
                size="mini"
                style="margin-left: 10px"
                type="primary"
                icon="el-icon-plus"
                @click="
                  dialogFormVisible = true
                  addAchi()
                "
              ></el-button>
            </el-tooltip>
          </div>
        </el-col>
        <el-col :span="24" class="people-table">
          <el-table :data="tableData" border style="width: 100%">
            <!-- <el-table-column prop="index" type="index" label="id" width="50">
            </el-table-column> -->
            <el-table-column
              prop="achievement_name"
              label="成果名称"
              width="200"
            >
            </el-table-column>
            <el-table-column prop="achievement_number" label="字数" width="60">
            </el-table-column>
            <el-table-column
              prop="achievement_author"
              label="署名人"
              width="150"
            >
            </el-table-column>
            <!-- <el-table-column
              prop="achievement_type"
              label="成果形态"
              width="150"
            >
            </el-table-column> -->
            <el-table-column
              prop="achievement_publish_time"
              label="发表时间"
              width="120"
            >
            </el-table-column>
            <el-table-column prop="achievement" label="获奖情况" width="140">
            </el-table-column>
            <el-table-column
              prop="achievement_publish"
              label="刊物名称或出版单位"
              width="160"
            >
            </el-table-column>
            <el-table-column label="操作" width="">
              <template slot-scope="scope">
                <el-row>
                <el-button
                  size="mini"
                  type="success"
                  icon="el-icon-edit"
                  @click="
                    dialogFormVisible = true
                    updateAchi(scope.row)
                  "
                  >修改</el-button
                >
                <el-button
                  size="mini"
                  type="warning"
                  icon="el-icon-delete"
                  @click="deleteAchi(scope.row)"
                  >删除</el-button
                >
                </el-row>
              </template>
              <el-dialog
                width="35%"
                title="主要成果"
                :visible.sync="dialogFormVisible"
                :append-to-body="true"
              >
                <el-form :model="formAchi">
                  <table class="content" border cellspacing="0">
                    <tr>
                      <td class="left"><span class="red">*</span>成果名称</td>
                      <td class="right">
                        <el-input
                          prop="achievement_name"
                          type="text"
                          placeholder="请认真填写成果名称"
                          v-model="formAchi.achievement_name"
                          clearable
                        ></el-input>
                      </td>
                    </tr>
                    <tr>
                      <td class="left"><span class="red">*</span>成果形态</td>
                      <td class="right">
                        <el-input
                          type="text"
                          placeholder="请填写专著、教材、论文或者研究报告（至多两项）"
                          v-model="formAchi.achievement_type"
                          clearable
                        ></el-input>
                      </td>
                    </tr>
                    <tr>
                      <td class="left"><span class="red">*</span>署名人</td>
                      <td class="right">
                        <el-input
                          type="text"
                          placeholder="请认真填写"
                          v-model="formAchi.achievement_author"
                          clearable
                        ></el-input>
                      </td>
                    </tr>
                    <tr>
                      <td class="left">
                        <span class="red">*</span>刊物名称或出版单位
                      </td>
                      <td class="right">
                        <el-input
                          type="textarea"
                          autosize
                          placeholder="请认真填写"
                          v-model="formAchi.achievement_publish"
                          clearable
                        ></el-input>
                      </td>
                    </tr>
                    <tr>
                      <td class="left"><span class="red">*</span>字数(万字)</td>
                      <td class="right">
                        <el-input
                          oninput="value=value.replace(/[^\d.]/g, '')"
                          placeholder="请认真填写"
                          v-model="formAchi.achievement_number"
                          clearable
                        ></el-input>
                      </td>
                    </tr>
                    <tr>
                      <td class="left"><span class="red">*</span>获奖情况</td>
                      <td class="right">
                        <el-input
                          type="text"
                          placeholder="请认真填写"
                          v-model="formAchi.achievement"
                          clearable
                        ></el-input>
                      </td>
                    </tr>
                    <tr>
                      <td class="left"><span class="red">*</span>发表时间</td>
                      <td class="right">
                        <el-date-picker
                          v-model="formAchi.achievement_publish_time"
                          type="date"
                          placeholder="请认真填写"
                          style="width:100%"
                          clearable>
                        </el-date-picker>
                        <!-- <el-input
                          type="date"
                          placeholder="请认真填写"
                          v-model="formAchi.achievement_publish_time"
                          clearable
                        ></el-input> -->
                      </td>
                    </tr>
                  </table>
                </el-form>
                <div slot="footer" class="dialog-footer">
                  <el-button @click="dialogFormVisible = false"
                    >取 消</el-button
                  >
                  <el-button
                    type="primary"
                    @click.native.prevent="serveAchi(formAchi)"
                    >确 定</el-button
                  >
                </div>
              </el-dialog>
            </el-table-column>
          </el-table>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="24"><h4 class="intro-center">总结报告</h4></el-col>
        <el-col :span="24">
          <div id="editor">
            <!-- this.$refs.ue.getUEContent()取编辑框数据 -->
            <UE
              :defaultMsg="defaultMsg"
              :config="config"
              ref="ue1"
              :id="ue1"
              :placeholder="1"
            ></UE>
          </div>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="7">
          <p style="margin-top:10%;margin-left:35%;">附件上传:</p>
        </el-col>
        <el-col :span="7" >
          <div style="margin-left: -40%;margin-top: 8%;">
            <el-upload
              class="upload-demo"
              action="http://8.142.34.26:8097/php/index.php/admin/Upload/SupportInput"
              :data="{pid: '2'}"
              :on-preview="handlePreview"
              :on-remove="handleRemove"
              :on-success="handleSuccess"
              :before-remove="beforeRemove"
              multiple
              :limit="3"
              :on-exceed="handleExceed"
              :file-list="fileList">
              <el-button size="small" type="primary">点击上传</el-button>
              <div slot="tip" class="el-upload__tip">只能zip/rar上传文件，且不超过20MB</div>

            <!--   <el-button style="margin-left: 10px;" size="small" type="success" @click="submitUpload">上传到服务器</el-button> -->
              </el-upload>
            </div>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="24">
          <div style="text-align: center; padding-bottom: 20px">
            <el-button style="background-color: #eef6fd" @click="cancel()"
              >返 回</el-button
            >
            <el-button type="primary" class="btn2" @click="submitAll(form)"
              >提 交</el-button
            >
          </div>
        </el-col>
      </el-row>
    </div>
  </div>
</template>

<script>
import http from '../../../../assets/js/http.js'
import UE from '../../../ue.vue'
export default {
  props: {},
  data() {
    return {
      fileList:[],
      ue1:'ue1',
      dialogFormVisible: false,
      class: '',
      topic: '',
      nowYear: '',
      final_result: [],
      form: {
        all_fee: '',
        real_date: '',
        identify_date: '',
        agr_expense: '',
        real_expense: '',
        mating_expense: '',
        matreal_expense: '',
        realtotal_expense: '',
        book_fee: '',
        book_fee_basis: '',
        data_fee: '',
        data_fee_basis: '',
        travel_fee: '',
        travel_fee_basis: '',
        international_fee: '',
        international_fee_basis: '',
        labour_fee: '',
        labour_fee_basis: '',
        administration_fee: '',
        administration_fee_basis: '',
        print_fee: '',
        print_fee_basis: '',
        equipment_fee: '',
        equipment_fee_basis: '',
        consulting_fee: '',
        consulting_fee_basis: '',
        meeting_fee: '',
        meeting_fee_basis: '',
        other_fee: '',
        other_fee_basis: '',
        provincial_fund: '',
        sch_fund: '',
        personal_fund: '',
        funds: '',
        id: ''
      },
      formAchi: {
        achievement_name: '',
        achievement_type: '',
        achievement_author: '',
        achievement_publish: '',
        achievement: '',
        achievement_number: '',
        achievement_publish_time: ''
      },
      tips: {
        real_dateTips: '实际完成时间',
        identify_dateTips: '申请鉴定时间',
        agr_expenseTips: '批准经费',
        real_expenseTips: '实拨经费',
        mating_expenseTips: '配套经费',
        matreal_expenseTips: '实拨经费',
       // realtotal_expenseTips: '项目实际总费',
        provincial_fundTips: '省级资助',
        sch_fundTips: '学校配套资助',
        personal_fundTips: '个人自筹',
        //fundsTips: '总经费',
        book_feeTips: '书本费',
        data_feeTips: '数据采集费',
        travel_feeTips: '差旅费',
        international_feeTips: '国际合作费',
        labour_feeTips: '劳务费',
        administration_feeTips: '管理费',
        print_feeTips: '印刷费',
        equipment_feeTips: '设备费',
        consulting_feeTips: '专家咨询费',
        meeting_feeTips: '会议费',
        other_feeTips: '其他支出'
      },
      tipsOne: {
        achievement_nameTips: '成果名称',
        achievement_typeTips: '成果形态',
        achievement_authorTips: '署名人',
        achievement_publishTips: '出版相关信息',
        achievement_number: '字数',
        achievement: '获奖情况',
        achievement_publish_time: '发表时间'
      },
      achievements: Lockr.get('achievements'),
      achievement: [],
      rules: {},
      defaultMsg:
        '实践育人项目主要内容提示：1.内容应由项目主持人撰写；文章内容要层次清楚、观点明晰、用语准确、文风朴实，要有实质性内容，并具有整体性和系统性，不得简单排列篇章目录；成果形式为出版物，或者3000左右文字材料或调研报告，附图片及其他佐证材料复印件或原件，具体依据实际情况确定。2.项目预期研究计划的执行情况；成果研究内容及方法的创新程度、突出特色；成果的创新实践性以及社会影响和效益；成果存在的不足或欠缺，尚需深入研究的问题等。学工精品项目提示：简要概括3000字左右，包括：1．项目计划的执行情况；2．主要成效及经验；3．存在的问题；4.改进措施，等等。具体可另附总结报告。',
      config: {
        initialFrameWidth: '100%',
        initialFrameHeight: 150,
        wordCount:3000
      },
      tableData: [],
      last: '',
      index: '',
      loading: true
    }
  },
  methods: {
     handlePreview(file) {
      var a = document.createElement('a');
      var event = new MouseEvent('click');
      a.download = file.name;
      a.href = 'http://' + file.url;
      a.dispatchEvent(event);
    },
    handleSuccess(response, file, fileList) {
      if(response.code != 200){
        _g.toastMsg('error',response.error)
      }
      this.form.file_id = response.data.file_id
      console.log(this.form)
    },
     handleChange(file, fileList) {
        this.fileList = fileList.slice(-3);
    },
    beforeRemove(file, fileList) {
      console.log(fileList)
        return this.$confirm(`确定移除 ${ file.name }？`);
    },

    // 初始化函数
    init() {
      // this.UESet()
      // window.UE.getEditor("editor", {wordCount:true,maximumWords:3000})
      this.getYear()
    },
    // 点击取消按钮当前页面刷新
    cancel() {
      this.$confirm('此操作将清空界面数据, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      })
        .then(() => {
          /* this.$message({
            type: 'success',
            message: '取消成功!'
          })
          this.$router.go(0) */
          this.$router.push({
            name: 'stdetailpro',
            params: {
              id: this.$route.params.subId,
              class: this.$route.params.class,
              endData: this.$route.params.endData,
              saveData: this.$route.params.saveData
            }
          })
        })
        .catch(() => {
          this.$message({
            type: 'info',
            message: '已取消清空'
          })
        })
    },
    // 添加主要成果
    addAchi() {
      this.formAchi = {}
      this.last = 1
    },
    // 修改主要成果
    updateAchi(row) {
      this.formAchi = row
      this.index = this.tableData.indexOf(row)
      this.last = 2
    },
    // 删除主要成果
    deleteAchi(row) {
      var rowind = this.tableData.indexOf(row)
      this.$confirm('此操作将永久删除该成员, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      })
        .then(() => {
          this.$message({
            type: 'success',
            message: '删除成功!'
          })
          // 删除操作
          this.achievement.splice(rowind, 1)
          this.tableData = this.achievement
          console.log(this.achievement)
        })
        .catch(() => {
          this.$message({
            type: 'info',
            message: '已取消删除'
          })
        })
    },
    // 保存主要成果前的验证
    serveAchi(obj) {
      this.timeDealTwo()
      // this.timeDeal()
      let curList = JSON.parse(JSON.stringify(obj))
      console.log(obj)
      var checkResult = this.checkList(obj, [
        {
          name: 'achievement_name',
          reg: ['notnull']
        },
        {
          name: 'achievement_type',
          reg: ['notnull']
        },
        {
          name: 'achievement_author',
          reg: ['notnull']
        },
        {
          name: 'achievement_publish',
          reg: ['notnull']
        },
        {
          name: 'achievement_number',
          reg: ['notnull']
        },
        {
          name: 'achievement',
          reg: ['notnull']
        },
        {
          name: 'achievement_publish_time',
          reg: ['notnull']
        }
      ])
      if (_g.j2s(checkResult) === '{}') {
        if (this.last === 1) {
          // 添加
          this.achievement.push(curList)
        }
        if (this.last === 2) {
          // 修改
          for (let i = 0; i < this.achievement.length; i++) {
            if (this.index === i) {
              this.achievement[i] === curList
            }
          }
        }
        this.last = ''
        console.log(this.achievement)
        this.tableData = this.achievement
        this.dialogFormVisible = false
      } else {
        for (const key in checkResult) {
          _g.toastMsg('warning', this.tipsOne[key] + '不能为空')
          break
        }
      }
    },
    // 提交数据前的验证
    submitAll(data) {
      // console.log(data)
      var arr = []
      if (this.class == 14) {
        arr = [
          {
            name: 'real_date',
            reg: ['notnull']
          },
          {
            name: 'identify_date',
            reg: ['notnull']
          },
          {
            name: 'agr_expense',
            reg: ['notnull']
          },
          {
            name: 'mating_expense',
            reg: ['notnull']
          },
          {
            name: 'real_expense',
            reg: ['notnull']
          },
          {
            name: 'matreal_expense',
            reg: ['notnull']
          },
          // {
          //   name: 'realtotal_expense',
          //   reg: ['notnull']
          // },
          {
            name: 'book_fee',
            reg: ['notnull']
          },
          {
            name: 'data_fee',
            reg: ['notnull']
          },
          {
            name: 'travel_fee',
            reg: ['notnull']
          },
          {
            name: 'meeting_fee',
            reg: ['notnull']
          },
          {
            name: 'international_fee',
            reg: ['notnull']
          },
          {
            name: 'equipment_fee',
            reg: ['notnull']
          },
          {
            name: 'consulting_fee',
            reg: ['notnull']
          },
          {
            name: 'labour_fee',
            reg: ['notnull']
          },
          {
            name: 'print_fee',
            reg: ['notnull']
          },
          {
            name: 'administration_fee',
            reg: ['notnull']
          },
          {
            name: 'other_fee',
            reg: ['notnull']
          }
        ]
      } else {
        arr = [
          {
            name: 'real_date',
            reg: ['notnull']
          },
          {
            name: 'identify_date',
            reg: ['notnull']
          },
          {
            name: 'provincial_fund',
            reg: ['notnull']
          },
          {
            name: 'sch_fund',
            reg: ['notnull']
          },
          {
            name: 'personal_fund',
            reg: ['notnull']
          },
          // {
          //   name: 'funds',
          //   reg: ['notnull']
          // },
          {
            name: 'book_fee',
            reg: ['notnull']
          },
          {
            name: 'data_fee',
            reg: ['notnull']
          },
          {
            name: 'travel_fee',
            reg: ['notnull']
          },
          {
            name: 'meeting_fee',
            reg: ['notnull']
          },
          {
            name: 'international_fee',
            reg: ['notnull']
          },
          {
            name: 'equipment_fee',
            reg: ['notnull']
          },
          {
            name: 'consulting_fee',
            reg: ['notnull']
          },
          {
            name: 'labour_fee',
            reg: ['notnull']
          },
          {
            name: 'print_fee',
            reg: ['notnull']
          },
          {
            name: 'administration_fee',
            reg: ['notnull']
          },
          {
            name: 'other_fee',
            reg: ['notnull']
          }
        ]
      }
      var checkResult = this.checkList(data, arr)
      if (_g.j2s(checkResult) === '{}') {
        this.submit()
      } else {
        console.log(checkResult)
        for (const key in checkResult) {
          _g.toastMsg('warning', this.tips[key] + '不可为空')
          break
        }
      }
    },
    // 提交数据
    submit() {
      this.timeDeal()
      this.timeDealOne()
      this.timeDealTwo()
      this.form.id = this.$route.params.id
      if(this.all_fee < 0 || this.realtotal_expense < 0 || this.funds < 0){
        _g.toastMsg("error","经费不能为负数！")
      }else{
        this.form.all_fee = this.all_fee;
        this.form.realtotal_expense = this.realtotal_expense;
        this.form.funds = this.funds;
        // console.log(this.$refs.ue1.getUEContent())
        if (
        this.$refs.ue1.getUEContent() != '<p>' + this.defaultMsg + '</p>' &&
        this.$refs.ue1.getUEContent() != ''
      ) {
        let data = {
          form: this.form,
          final_result: this.final_result,
          achievement: this.achievement,
          total_report: this.$refs.ue1.getUEContent()
        }
         console.log(data)
        this.apiPost('admin/Report/EndWrite', data).then(res => {
          this.handelResponse(res, data => {
            console.log(res)
            _g.toastMsg('success', '提交成功')
            this.$router.push({
              name: 'stdetailpro',
              params: {
                id: this.$route.params.subId,
                class: this.$route.params.class,
                endData: this.$route.params.endData,
                saveData: this.$route.params.saveData
              }
            })
            this.loading = false
          })
        })
      } else {
        _g.toastMsg('warning', '请填写总结报告')
      }
      }
      // this.form.id = 9
     
    },
    // 处理日期格式
    timeDeal() {
      let date = new Date(this.form.real_date)
      let year = date.getFullYear()
      let month = date.getMonth() + 1
      let day = date.getDate()
      if (month < 10) {
        month = '0' + month
      }
      if (day < 10) {
        day = '0' + day
      }
      this.form.real_date = year + '-' + month + '-' + day
    },
    timeDealOne() {
      let date = new Date(this.form.identify_date)
      let year = date.getFullYear()
      let month = date.getMonth() + 1
      let day = date.getDate()
      if (month < 10) {
        month = '0' + month
      }
      if (day < 10) {
        day = '0' + day
      }
      this.form.identify_date = year + '-' + month + '-' + day
    },
    timeDealTwo() {
      let date = new Date(this.formAchi.achievement_publish_time)
      let year = date.getFullYear()
      let month = date.getMonth() + 1
      let day = date.getDate()
      if (month < 10) {
        month = '0' + month
      }
      if (day < 10) {
        day = '0' + day
      }
      this.formAchi.achievement_publish_time = year + '-' + month + '-' + day
    },
    // 为编辑器设置placeholder
    UESet() {
      window.UE.Editor.prototype.placeholder = function(justPlainText) {
        var _editor = this
        _editor.addListener('focus', function() {
          var localHtml = _editor.getPlainTxt()
          if ($.trim(localHtml) === $.trim(justPlainText)) {
            _editor.setContent(' ')
          }
        })
        _editor.addListener('blur', function() {
          var localHtml = _editor.getContent()
          if (!localHtml) {
            _editor.setContent(justPlainText)
          }
        })
        _editor.ready(function() {
          _editor.fireEvent('blur')
        })
      }
      // 实例化编辑器example
      var editor = window.UE.getEditor('editor')
      editor.placeholder(
        '主要内容提示：1.内容应由项目主持人撰写；文章内容要层次清楚、观点明晰、用语准确、文风朴实，要有实质性内容，并具有整体性和系统性，不得简单排列篇章目录；成果形式为出版物，或者3000左右文字材料或调研报告，附图片及其他佐证材料复印件或原件，具体依据实际情况确定。2.项目预期研究计划的执行情况；成果研究内容及方法的创新程度、突出特色；成果的创新实践性以及社会影响和效益；成果存在的不足或欠缺，尚需深入研究的问题等。'
      )
    },
    // 当前年
    getYear() {
      this.nowYear = new Date().getFullYear()
    },
    // 多选框选择
    mulCheck(value) {
      this.predict_result = value
    },
    mulCheckOne(value) {
      this.final_result = value
    }
  },
  created() {
    _g.closeGlobalLoading()
    this.class = this.$route.params.class
    this.init()
  },
  watch: {},
  computed: {
    all_fee: function(){
      if(isNaN(this.form.book_fee)&&isNaN(this.form.data_fee)&&isNaN(this.form.travel_fee)&&isNaN(this.form.international_fee)&&isNaN(this.form.equipment_fee)&&isNaN(this.form.consulting_fee)&&NaN(this.form.labour_fee)&&isNaN(this.form.print_fee)&&isNaN(this.form.administration_fee)&&isNaN(this.form.other_fee)&&isNaN(thi&&s.form.meeting_fee)){
          return 0
        }else{
           return  parseInt(this.form.book_fee*100 + this.form.data_fee*100 + this.form.travel_fee*100+ this.form.international_fee*100+ this.form.equipment_fee*100+ this.form.consulting_fee*100+ this.form.labour_fee*100+ this.form.print_fee*100+ this.form.administration_fee*100+ this.form.other_fee*100+ this.form.meeting_fee*100)/100  
      }
    },
    realtotal_expense: function(){
      if(isNaN(this.form.real_expense)&&isNaN(this.form.matreal_expense)){
        return 0
      }else{
        return parseInt(this.form.real_expense*100 + this.form.matreal_expense*100)/100
      }
    },
    funds: function(){
      if(isNaN(this.form.provincial_fund)&&isNaN(this.form.sch_fund)&&isNaN(this.form.personal_fund)){
        return 0
      }else{
        return parseInt(this.form.provincial_fund*100 + this.form.sch_fund*100 + this.form.personal_fund*100 )/100
      }
    }
  },
  components: { UE },
  mounted() {
    /*  window.addEventListener('keyup', (e) => {
      if (e.keyCode === 13) {
        // 调用的函数
      }
    }) */
  },
  mixins: [http]
}
</script>
<style scoped>
.wrapper {
  padding: 1px;
  background: #fff;
  border-top: 3px solid #3c8dbc;
}
.formall {
  background: #fff;
  padding: 0 2% 10px 2%;
}
.cell-width {
  width: 90%;
}
.expense-width {
  width: 70%;
}
.intro-center {
  text-align: center;
  padding-bottom: 5px;
}
#editor {
  margin: 0 5% 20px 5%;
}
.left {
  width: 200px;
  text-align: right;
  padding-right: 10px;
  font-family: '微软雅黑';
}
.right {
  width: 400px;
  padding: 4px;
}
.red {
  color: red;
  padding-right: 3px;
}
.content {
  border-color: #e8f6f9;
}
.content tr:nth-child(even) {
  background: #fff;
}
.content tr:nth-child(odd) {
  background: #f2f9ff;
}
.people-table {
  padding: 0 4.9% 0 4.9%;
}
</style>
